package lion.framework.core.bean.anno;

import java.lang.annotation.Annotation;

import org.apache.commons.lang.StringUtils;

import lion.dev.lang.MapJ;
import lion.framework.core.anno.AnnoProcessor;
import lion.framework.core.anno.AnnotationProcessorManager;
import lion.framework.core.anno.IAnnotationProcessor;

/**
 * @author lion
 * @email hl_0074@sina.com
 * @date 2015年9月21日
 */
@AnnoProcessor(Bean.class)
public class BeanAnnoProcessor implements IAnnotationProcessor {

	@Override
	public void processe(MapJ ctx, Annotation anno) throws Exception {

		Class<?> clazz = (Class<?>) ctx.getE(AnnotationProcessorManager.ANNO_CONTEXT_CLASS);
		Bean bean = (Bean) anno;
		String name = bean.value();
		if (StringUtils.isBlank(name)) {
			name = clazz.getName();
		}
		RegisteredBean.registe(name, clazz);
	}
}
